<template>
	<view class="list">
		<uni-row :width="nvueWidth" :gutter="25">
			<uni-col :span="12" v-for="(item,index) in list" :key="index">
				<view class="list-con"  @click="goTo(`../../agricultureLecture/classDetails/${item.type == 1?'classDetails':'video'}?id=${item.serviceId}`)">
					<view class="list-img" v-if="item.image">
						<image class="image" mode="widthFix"
							:src="imgUrl + item.image + '?x-image-process=style/style-list'"></image>
						<text class="img-icon">精品课堂</text>
					</view>
					<view class="list-img" v-else>
						<image class="image" src="https://staticfile-yj.obs.cn-north-4.myhuaweicloud.com/none.png" mode="widthFix">
						</image>
						<text class="img-icon">精品课堂</text>
					</view>
					<text class="list-text">{{item.title}}</text>
					<view class="uni-flex list-info">
						<view class="author">
							<image src="https://staticfile-yj.obs.myhuaweicloud.com/%E5%86%9C%E5%8F%8B%E5%9C%88.png"></image><text>{{item.expertName}}</text>
						</view>
						<view class="see"><uni-icons type="eye" color="#9498A0"
								size="14"></uni-icons><text>{{item.browseNum}}</text></view>
					</view>
				</view>
			</uni-col>
		</uni-row>
		<uni-load-more :status="LoadMore" :content-text="contentText"
			></uni-load-more>
	</view>
</template>

<script>
	import {
		baseurl,
		pageCourseQueryCollection
	} from "@/api/user.js";
	let imgUrl = "https://nongmao.obs.cn-north-4.myhuaweicloud.com/"
	export default {
		data() {
			return {
				nvueWidth: 730,
				list: [],
				page: 1,
				maxpage: 0,
				showLoadMore: false,
				imgUrl,
				LoadMore: 'noMore',
				contentText: {
					contentdown: '...',
					contentrefresh: '加载中',
					contentnomore: '暂无更多数据'
				},
			};
		},
		onLoad() {
			this.initData();
		},
		onPullDownRefresh() {
			console.log('onPullDownRefresh');
			this.initData();
		},
		onReachBottom() {
			console.log("onReachBottom");
			console.log("page", this.page, this.maxpage)
			if (this.page == this.maxpage) {
				this.LoadMore = 'noMore';
				return
			}
			this.LoadMore = 'loading';
			this.page++;
			this.pageCourseQueryCollection({ //参数
				"condition": null,
				"pageNum": this.page,
				"pageSize": 10
			});
		},
		methods:{
			async pageCourseQueryCollection(options) {
				const res = await pageCourseQueryCollection(options)
				console.log(res);
				this.maxpage = res.returnObj.navigateLastPage;
				this.list = this.list.concat(res.returnObj.list);
				this.LoadMore = 'noMore';
			},
			initData() {
				this.page = 1;
				this.list = [];
				this.LoadMore = "loading";
				this.pageCourseQueryCollection({ //参数
					"condition": null,
					"pageNum": this.page,
					"pageSize": 10
				});
				uni.stopPullDownRefresh();
			},
			goTo(e) {
				var url = e;
				uni.navigateTo({
					url: url
				})
			},
		}
	}
</script>

<style lang="scss">
.list {
		padding: 15px 30rpx;
	}
	
	.list-con {
		width: 100%;
		padding: 0px;
		margin-bottom: 15px;
		background-color: #ffffff;
		border-radius: 8px;
	}
	
	.list-img {
		position: relative;
	}
	
	.list-img .img-icon {
		position: absolute;
		left: 0;
		top: 0;
		display: inline-block;
		width: 128rpx;
		height: 48rpx;
		line-height: 48rpx;
		font-size: 24rpx;
		text-align: center;
		color: #ffffff;
		background-image: url('https://staticfile-yj.obs.myhuaweicloud.com/tag-1.png');
		background-repeat: no-repeat;
		background-size: 100% 100%;
	}
	
	.list-img .image {
		width: 100%;
		border-radius: 8px 8px 0px 0px;
	}
	
	
	.list-text {
		font-size: 28rpx;
		color: #283241;
		line-height: 22px;
		max-height: 44px;
		padding: 0 10rpx;
		overflow: hidden;
		font-weight: bold;
	}
</style>
